<?php
	class homepage extends CI_Controller {

		function __construct()
		{
			parent::__construct();
			$this->load->model('modimagecontent');
			$this->load->model('modsetmenu');
			$this->load->model('modsinglecontent');
			$this->load->model('modmulticontent');
			$this->load->model('modmulticontainer');
			$this->load->model('modalbum');
			$this->load->model('modpicture');
		}
		
		public function index()
		{
			$idMenuSambutan = 14; //sambutan gubernur
			$idMenuBerita = 19; //Limit berita
		
			$data['logo'] = $this->modimagecontent->getImageContent(1);
			$data['slide'] = $this->modimagecontent->getImageContent(2);
			$data['sponsor'] = $this->modimagecontent->getImageContent(3);
			
			$data['mainNavContent'] = $this->modsetmenu->navList();
			$data['subNavContent'] = $this->modsetmenu->subNavList();
			
			$data['beritaContent'] = $this->modmulticontent->getBeritaLimitContent($idMenuBerita);
			$data['sambutanContent'] = $this->modsinglecontent->getSingleContent($idMenuSambutan);
			
			$this->load->view('webcontent/layout',$data);
		}
		
		function content($id_menu){
			if($id_menu == 5){ //beranda
				$idMenuSambutan = 14; //sambutan gubernur
				$idMenuBerita = 19; //Limit berita
			
				$data['logo'] = $this->modimagecontent->getImageContent(1);
				$data['slide'] = $this->modimagecontent->getImageContent(2);
				$data['sponsor'] = $this->modimagecontent->getImageContent(3);
				
				$data['mainNavContent'] = $this->modsetmenu->navList();
				$data['subNavContent'] = $this->modsetmenu->subNavList();
				
				$data['beritaContent'] = $this->modmulticontent->getBeritaLimitContent($idMenuBerita);
				$data['sambutanContent'] = $this->modsinglecontent->getSingleContent($idMenuSambutan);
			}else{				if($id_menu == 19){					$config['base_url'] = base_url().'homepage/content/19/';									}				if($id_menu == 20){					$config['base_url'] = base_url().'homepage/content/20/';				}				$this->db->where('id_menu', $id_menu);				$this->db->from('multi_container');				$this->db->join('multi_content', 'multi_content.id_multi_content = multi_container.id_multi_content','left');				$config['total_rows'] = $this->db->count_all_results('');				$config['per_page'] = 5;				$config['uri_segment'] = 4;								$config['full_tag_open'] = '<div class="pagination"><ul>';				$config['full_tag_close'] = '</ul></div><!--pagination-->';				$config['first_link'] = '&laquo; First';				$config['first_tag_open'] = '<li>';				$config['first_tag_close'] = '</li>';								$config['last_link'] = 'Last &raquo;';				$config['last_tag_open'] = '<li>';				$config['last_tag_close'] = '</li>';				$config['next_link'] = 'Next &rarr;';				$config['next_tag_open'] = '<li>';				$config['next_tag_close'] = '</li>';				$config['prev_link'] = '&larr; Previous';				$config['prev_tag_open'] = '<li>';				$config['prev_tag_close'] = '</li>';								$config['cur_tag_open'] = '<li><a href="#" class="page active">';				$config['cur_tag_close'] = '</a></li>';				$config['num_tag_open'] = '<li>';				$config['num_tag_close'] = '</li>';				$this->pagination->initialize($config);				$offset=($this->uri->segment(4)) ? $this->uri->segment(4) : 0;			
				$data['logo'] = $this->modimagecontent->getImageContent(1);
				$data['mainNavContent'] = $this->modsetmenu->navList();
				$data['subNavContent'] = $this->modsetmenu->subNavList();
				$data['singleContent'] = $this->modsinglecontent->getSingleContent($id_menu);
				$data['multiContent'] = $this->modmulticontent->getListBeritaContent($id_menu,$config['per_page'],$offset);
				$data['albumContent'] = $this->modalbum->getAlbumByMenu($id_menu);
			}
			$this->load->view('webcontent/layout',$data);
		}
		
		function pictures($id_album){
			$data['logo'] = $this->modimagecontent->getImageContent(1);
		
			$data['mainNavContent'] = $this->modsetmenu->navList();
			$data['subNavContent'] = $this->modsetmenu->subNavList();
			
			$data['listPicture'] = $this->modpicture->getImgDetail($id_album);
			
			$this->load->view('webcontent/layout',$data);
		}
		
		function readmore($id_content){
			$data['logo'] = $this->modimagecontent->getImageContent(1);
		
			$data['mainNavContent'] = $this->modsetmenu->navList();
			$data['subNavContent'] = $this->modsetmenu->subNavList();
			
			$data['multiDetailContent'] = $this->modmulticontainer->getDetailContent($id_content);
			$this->load->view('webcontent/layout',$data);
		}
		
		function singlereadmore($id_content){
			$data['logo'] = $this->modimagecontent->getImageContent(1);
		
			$data['mainNavContent'] = $this->modsetmenu->navList();
			$data['subNavContent'] = $this->modsetmenu->subNavList();
			
			$data['singleContent'] = $this->modsinglecontent->getDetailContent($id_content);
			$this->load->view('webcontent/layout',$data);
		}
		
		function downloadfile($id_menu){
			$unduh = $this->modsinglecontent->getSingleContent($id_menu);
		
			$data = file_get_contents(base_url().'images/uploads/content_files/'.$unduh[0]['file_upload']);
			force_download($unduh[0]['file_upload'], $data);
		}
		
	}
?>